Skip to content

Conversation

@dimaip
Copy link

@dimaip dimaip commented Aug 24, 2018

WARNING: I'm a TS n00b, this is my first day with it.

Take a simple class-based react component and try to wrap it with themr:

import React from 'react';
import {themr} from '@friendsofreactjs/react-css-themr';

interface LabelProps {
    [x: string]: any;
}

class Label extends React.Component<LabelProps> {
    render() {
        return <div/>;
    }
}

themr('123', {})(Label);

You'd get an error:

[ts]
Argument of type 'typeof Label' is not assignable to parameter of type '(new (props?: LabelProps | undefined, context?: any) => Component<LabelProps, {}, any>) | StatelessComponent<LabelProps>'.
  Type 'typeof Label' is not assignable to type 'StatelessComponent<LabelProps>'.
    Type 'typeof Label' provides no match for the signature '(props: LabelProps & { children?: ReactNode; }, context?: any): ReactElement<any> | null'.

This happens because themr defines props as optional where as @type/react defines it as mandatory: new (props: P, context?: any): Component<P, S>; .

@markusguenther markusguenther merged commit 9ab46f6 into FriendsOfReactJS:develop Aug 25, 2018
@markusguenther
Copy link
Member

Thanks @dimaip for your contribution :)

@markusguenther
Copy link
Member

🎉 This PR is included in version 3.3.2 🎉

The release is available on:

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants